package com.jr.Dao.Impl;

import com.jr.Dao.ILoginDao;
import com.jr.Pojo.Users;
import com.jr.util.DBHelper;

import java.util.ArrayList;

public class LoginDaoImpl implements ILoginDao {
    DBHelper db = new DBHelper();
    @Override
    public int insertUsers(Users users) {
        String sql="insert into users value(null,?,?,?,default,default)";
        Object[] objs = {users.getUsername(),users.getPassword(),users.getRole()};
        return db.dtUpdate(sql,objs);
    }

    @Override
    public ArrayList<Users> selectPasswordByUsername(String username) {
        String sql="select * from users where username=?";
        Object[] objs={username,};
        return db.dtQuery(sql,Users.class,objs);
    }

    @Override
    public ArrayList<Users> selectAll() {
        String sql="select * from users";
        return db.dtQuery(sql,Users.class);
    }


}
